package com.tt.mymu.controller;

import com.tt.mymu.entity.Info;
import com.tt.mymu.entity.po.InfoPO;
import com.tt.mymu.service.InfoService;
import com.tt.mymu.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("info")
public class InfoController {
    @Autowired
    private InfoService infoService;

    @RequestMapping("getListInfoByVo")
    public Result getListInfoByVo(
            InfoPO infoPO,
            @RequestParam(value = "page", defaultValue = "1") int page,
            @RequestParam(value = "size", defaultValue = "10") int size) {
        return infoService.getListInfoByVo(infoPO, page, size);
    }

    /**
     * 获取所有列表   最热888，最新888
     * 前端页面展示数据接口
     *
     * @return
     */
    @RequestMapping("getListInfo")
    public Result getListInfo(int type,
                              @RequestParam(value = "page", defaultValue = "1") int page,
                              @RequestParam(value = "size", defaultValue = "10") int size) {
        return infoService.getListInfo(type, page, size);
    }

    @RequestMapping("addInfo")
    public Result addInfo(Info info) {
        return infoService.addInfo(info);
    }

    @RequestMapping("deleteInfo")
    public Result deleteInfo(Integer id) {
        return infoService.deleteInfo(id);
    }

    @RequestMapping("updateInfo")
    public Result updateInfo(Info info) {
        return infoService.updateInfo(info);
    }

    @RequestMapping("selectInfoByIdAndToken")
    public Result selectInfoById(Integer id, String token) {
        return infoService.selectInfoById(id, token);
    }

//    @RequestMapping("test")
//    public Result test(Integer id, String token) {
//        return null;
//    }
}
